$(function(){
	
	var vm = new Vue({
		el:'#Main',
		data:{
			swiper:'',
			//banner数据
			bannerData:testData.banner,
			//八大分类
			listData:testData.classify,
			//商品数据
			goodData:testData.product,
		},
		methods:{
			//跳转商品列表页
			skipProList:function(listId){
				location.href = 'allProduct.html?listId='+listId;
			},
		},
		//渲染完初始数据后执行
		mounted:function(){
			//创建banner
			createBanner('#banner');
			this.swiper = pullSwiper('#Main',true,true);
		},
		created:function(){
			imgRate();
		},
		watch:{
			swiper:function(obj){
				obj.on('touchMove transitionEnd',function(){
					var dist = obj.getTranslate();
					if(dist < -100){
						if($("#slideBar").find('.backTop').length == 0){
							$("#slideBar").append(`
								<a class="backTop flex-col">
									<span class="icon"><img src="image/icon/slide-icon.png" /></span>
								</a>
							`);
						};
					}else{
						if($("#slideBar").find('.backTop').length > 0){
							$("#slideBar").find('.backTop').remove();
						};
					};
				});
			},
		},
	});
	
	//回到顶部
	$("#slideBar").delegate('.backTop','click',function(){
		vm.swiper.setTransition(500);//设定过渡的时间
    	vm.swiper.setTranslate(0);//设定位移，可以为正数
    	$("#slideBar").find('.backTop').remove();
	});
	
});

//下拉刷新
function refresh(pull){
	pull.innerHTML='刷新完成';
};

//加载
function reload(pull){
	pull.innerHTML='已加载全部数据'
};
